function recursiveSed {
	# param 1 : sed expression
	read -N 1000000 input
	oldout="$input"
	newout=`echo "$oldout" | sed -re "$1"`
	while [ "$oldout" != "$newout" ]
	do
		oldout="$newout"
		newout=`echo "$oldout" | sed -re "$1"`
	done
	echo "$newout"
}

BEFORESPACES="    "
AFTERSPACES="~    \+ "
SPECIALTOKEN="SPECIALTOKEN"

catdvi -e 1 -U devresume.dvi | 
sed -re 's/\o014//g' |
sed -re "s/\[U\+2022\]/*/g" |
sed -re "s/([^^[:space:]])\s+/\1 /g" |
tr '\n' '~' |
sed -re "s/\&\&TextItemIndicate\&\&/       /g" |
sed -re "s/~$BEFORESPACES([^ ])/~$AFTERSPACES\1/g" |
sed -re "s/\&\&RightAlignMarker\&\&([^~]*)~/(\1)~/g" |
sed -re "s/([^~])(~[A-Z][^a-z]*~)/\1~\2/g" |
sed -re "s/(~[A-Z][^a-z]*~)~/\1/g" |
sed -re "s/~~~+/~~/g" |
sed -re "s/^ *//g" |
sed -re "s/(~[A-Z][^a-z]*)~[ ]+\* ([^~]*~)/\1$SPECIALTOKEN\2/g" |
recursiveSed "s/(~[A-Z][^a-z]*$SPECIALTOKEN[^~]*)~[ ]+\* ([^~]*~)/\1$SPECIALTOKEN\2/g" |
sed -re "s/$SPECIALTOKEN/$AFTERSPACES/g" |
sed -re "s/(~[A-Z][^a-z]*)$AFTERSPACES([^~]*~~)/\1~$BEFORESPACES\2/g" |
tr '~' '\n' > devresume.txt

cat devresume.txt |
tr '\n' '~' |
sed -re "s/~ + \* /\. /g" |
recursiveSed "s/\.\./\./g" |
tr '~' '\n' |
fold -w 80 -s > devresume.folded.txt
